package com.mall.users.service;

import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mall.model.domain.UmsAdminRoleRelation;
import com.mall.users.mapper.UmsAdminRoleRelationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UmsAdminRoleRelationService {


    @Autowired
    private UmsAdminRoleRelationMapper umsAdminRoleRelationMapper;

    /**
     * 根据用户id查询权限id
     * @param adminId
     * @return
     */
    public List<UmsAdminRoleRelation> findByAdminId(Long adminId) {
        return umsAdminRoleRelationMapper.selectByAdminId(adminId);
    }

    /**
     * 根据用户id删除与权限关联关系
     * @param adminId
     * @return
     */
    public void deleteByAdminId(Long adminId) {
        umsAdminRoleRelationMapper.deleteByAdminId(adminId);
    }

    /**
     * 新增用户和角色关系
     * @param relationList
     */
    public void save(List<UmsAdminRoleRelation> relationList) {
        umsAdminRoleRelationMapper.save(relationList);
    }

    /**
     * 根据角色id删除和用户的关系
     * @param ids
     */
    public void deleteByRoleIds(List<Long> ids) {
        umsAdminRoleRelationMapper.deleteByRoleIds(ids);
    }
}
